package com.android.hedgehog;

public class TripleSum {
	
	public int[] options;
	public int[] guesses;
	public int answer;
	public int operator = 0;
	public int operand0, operand1, operand2;
	public int difficulty;
	public int totalGuess = 0;

	public TripleSum(int level) {
		difficulty = level;
		operator = (difficulty > 5) ? 1 : 0;
		options = new int[8];
		guesses = new int[3];
		enumerateOptions();
		
	}

	private void enumerateOptions() {
		for (int i = 0; i < options.length; i++) {
			options[i] = (int) ((Math.random() * (12 + (difficulty % 4 + 1))) + 1);
		}
		operand0 = (int) ((Math.random() * 7) + 1);
		do {
			operand1 = (int) ((Math.random() * 7) + 1);
		} while (operand1 == operand0);
		do {
			operand2 = (int) ((Math.random() * 7) + 1);
		} while (operand0 == operand2 || operand1 == operand2);
		if (difficulty < 6)
			answer = options[operand0] + options[operand1] + options[operand2];
		else
			answer = options[operand0] * options[operand1] + options[operand2];
	}

	public boolean checkAnswer() {
		if (difficulty < 6)
			totalGuess = guesses[0] + guesses[1] + guesses[2];
		else
			totalGuess = guesses[0] * guesses[1] + guesses[2];
		if (answer == totalGuess)
			return true;
		else
			return false;
	}
}
